package com.weishaoying.thrift.learn.annotation;

import com.meituan.service.mobile.mtthrift.proxy.ThriftServerPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @author WeiShaoying
 * @date 2018/9/21
 */
@Configuration
@ComponentScan
public class JavaConfig {

    @Bean(name = "testService")
    public TestService testService() {
        return new TestServiceImpl();
    }

    /**
     *
     <bean id="userServiceServerPublisher" class="com.meituan.service.mobile.mtthrift.proxy.ThriftServerPublisher"
     init-method="publish" destroy-method="destroy">
     <property name="serviceInterface" value="com.weishaoying.thrift.learn.annotation.TestService"/> <!-- 接口类 -->
     <property name="serviceImpl" ref="testService"/> <!-- 实现类 -->
     <property name="appKey" value="com.sankuai.inf.mtthrift.testServer"/>  <!-- 本地 appkey，建议重新注册一个 -->
     <property name="port" value="9281"/>
     </bean>
     * @return
     */
    @Bean
    public ThriftServerPublisher thriftServerPublisher(){
        ThriftServerPublisher publisher = new ThriftServerPublisher();
        publisher.setServiceInterface(TestService.class);
        publisher.setServiceImpl(testService());
        publisher.setAppKey("com.sankuai.inf.mtthrift.testServer");
        publisher.setPort(9281);
        return publisher;
    }
}


